package org.hbbTlias2025.service.IMPL;

import lombok.extern.slf4j.Slf4j;
import org.hbbTlias2025.mapper.StudentMapper;
import org.hbbTlias2025.pojo.ClazzOption;
import org.hbbTlias2025.pojo.JobOption;
import org.hbbTlias2025.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.hbbTlias2025.mapper.EmpMapper;

import java.util.List;
import java.util.Map;

@Slf4j
@Service
public class ReportServiceImpl implements ReportService {

    @Autowired
    private EmpMapper empMapper;

    @Autowired
    private StudentMapper studentMapper;



    @Override
    public JobOption getEmpJobData() {
        JobOption jobOption = new JobOption();

        List<Map<String, Object>> list = empMapper.getEmpJobData();

        List<Object> joblist =  list.stream().map(data -> data.get("jobname")).toList();
        List<Object> datalist =  list.stream().map(data -> data.get("count")).toList();

        jobOption.setJobList(joblist);
        jobOption.setDataList(datalist);

        return jobOption;
    }

    @Override
    public List<Map<String, Object>> getEmpGenderData() {
        return empMapper.getEmpGenderData();
    }

    @Override
    public List<Map<String, Object>> getStudentDegreeData() {


        return studentMapper.getstudentDegreeData();
    }

    @Override
    public ClazzOption getStudentCountData() {
        ClazzOption clazzOption = new ClazzOption();

        List<Map<String, Object>> list = studentMapper.getStudentCountData();

        clazzOption.setClazzList(list.stream().map(data -> data.get("clazzName")).toList());
        clazzOption.setDataList(list.stream().map(data -> data.get("count")).toList());

        return clazzOption;

    }
}
